package com.mashibing.juc.c_001;

/**
 * @ClassName T05_TestSynchronized
 * @Description 测试共享数据 使用synchronized
 * @Author xiongwei.wu
 * @Date 2021/7/1 9:50
 **/
public class T05_TestSynchronized implements Runnable {

    private int count = 50;

    @Override
    public /*synchronized*/ void run() {
        count--;
        System.out.println(Thread.currentThread().getName() + " count = " + count);
    }

    public static void main(String[] args) {
        T05_TestSynchronized t = new T05_TestSynchronized();
        for (int i = 0; i < 50; i++) {
            new Thread(t, "Thread " + i).start();
        }
    }
}
